/*
 * @file    :task_system.c
 * @module  :SYSTEM TASK
 * @author  :LingFengLu
 * @date    :2023-06-08
 */

#include "task_system.h"
#include "task.h"
#include "drv.h"

//Constant definition    宏定义
#define TYPT_14    								0
#define TYPT_10                                 1
#define TYPT_7                                  2

#define DEVICE_TYPE                             TYPT_14
#define MAJOR_VERSION_NUMBER                    1
#define MINOR_VERSION_NUMBER                    7
#define REVISON_VERSION_NUMBER                  0
#define BUILD_VERSION_NUMBER                    3





//Type definition    类型定义


//Global variable definition    全局变量定义


//Private variable definition    私有变量定义
static device m_t_Device =
{
    {0, 0, 0, 0, 0, 0},
    DEVICE_ENDIAN_LITTLE,
    DEVICE_TYPE_METER,
    0,
    0,
    65535
};

//Private function declaration   私有函数申明








//Public function definition   公共函数定义

void TaskSystem_Init
(
	devos_task_handle t_TaskHandle
)
{
    uint8 u8_VersionNum1,u8_VersionNum2,u8_VersionNum3,u8_VersionNumBulid;
    uint8 u8_Type = DEVICE_TYPE;
    u8_VersionNum1 =MAJOR_VERSION_NUMBER;
    u8_VersionNum2 =MINOR_VERSION_NUMBER;
    u8_VersionNum3 =REVISON_VERSION_NUMBER;
    u8_VersionNumBulid = BUILD_VERSION_NUMBER;
    m_t_Device.u32_Version = (u8_VersionNum1<<24) + (u8_VersionNum2<<16) + (u8_VersionNum3<<8)  +u8_VersionNumBulid;
    m_t_Device.u32_Model = u8_Type;
}


void TaskSystem_Process
(
	devos_task_handle t_TaskHandle
)
{
    static uint8 *u8p_MessageData;
	static devos_int t_MessageLength;
    DEVOS_TASK_BEGIN

	DevOS_MessageWait(TASK_MESSAGE_ID_CLOCK, u8p_MessageData, &t_MessageLength);

    LOG_INFO("TaskSystem_Process");

    DEVOS_TASK_END
}

uint TaskSystem_SetConfig
(
	uint ui_Parameter,
	const uint8 *u8p_Value,
	uint ui_Length
)
{
    return FUNCTION_FAIL;
}
uint TaskSystem_GetConfig
(
	uint ui_Parameter,
	uint8 *u8p_Value,
	uint *uip_Length
)
{
	switch (ui_Parameter)
	{
	case TASK_SYSTEM_PARAM_DEVICE:
        Lib_Memcpy(u8p_Value, (const uint8 *)&m_t_Device,sizeof(m_t_Device));
		break;

	case TASK_SYSTEM_PARAM_BUSY:
		*u8p_Value = 0;
		break;
	
	case TASK_SYSTEM_PARAM_MEMORY:
        *((uint8 *)u8p_Value) = *((uint8 *)(*((uint *)u8p_Value)));
		break;
	
	default:
		return FUNCTION_FAIL;
	}
    return FUNCTION_OK;
}





//Private function definition   私有函数定义

